list = [
    {"id":"10086","book_name":'Photoshop入门到闯关',"date":'2015-05-10',"price":69.8,"kc":1},
    {"id":"10010","book_name":'十大名著',"date":'2024-05-10',"price":99.8,"kc":2},
    {"id":"10000","book_name":'水喉转',"date":'2024-12-10',"price":39.8,"kc":10},
]
# 显示书目信息
def info_book(list):
    for x in list:
        print(x['id'],"\t",x['book_name'],'\t',x['date'],'\t',x['price'])
# 显示图书库存信息
def info_kc(list):
    for x in list:
        print(x['id'],'\t',x['book_name'],'\t',x['kc'])
# 添加书目信息
def add_book(list):
    id = input('请输入书籍编号：')
    book_name = input('请输入书籍名称：')
    date = input('请输入出版时间：')
    price = float(input('请输入书籍定价：'))
    # list添加元素 append()
    list.append({"id":id,"book_name":book_name,"date":date,"price":price,"kc":1})
# 修改库存
def up_book(list):
    # 根据书籍编号更改库存量
    id = input('请输入书籍编号：')
    # 输入修改的库存量
    kc = int(input("请输入修改后的库存："))
    flag = False
    for x in list:
        # 判断找出这本书籍的字典
        if x['id']==id:
           # 开始修改库存
           x['kc']=kc
           flag = True
    if flag==False:
        print('没有该图书')
# 定义主菜单
def main():
    print('=============================')
    print('图书库存管理系统v1.0')
    while True:
        print('1.显示书目信息')
        print('2.显示图书库存信息')
        print('3.添加书目信息')
        print('4.修改图书库存量')
        print('5.退出系统')
        index = input('请输入要执行的操作：')
        if index=="1":info_book(list)
        if index=="2":info_kc(list)
        if index=="3":add_book(list)
        if index=="4":up_book(list)
main()